package com.aurora.CETManagementSystem.utils;

import com.aurora.CETManagementSystem.mapper.TestLogMapper;
import com.aurora.CETManagementSystem.pojo.TestLog;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class SomeUtils {

    @Resource
    TestLogMapper testLogMapper;

    //生成随机准考证
    public String cetNumGenerate(){
        String testNum ;
        int randint;
        TestLog oldLog;
        do{
            randint = (int)(Math.random() * 10000000);
            testNum = "41030020"+randint;
            oldLog = testLogMapper.selectOne(new QueryWrapper<TestLog>().eq("cetnum", testNum));
        }while(oldLog!=null);
        return testNum;
    }
}
